package org.example.ssmioc1.config;

import org.example.ssmioc1.datasource.MyDataSource;
import org.springframework.context.annotation.*;

@Configuration
public class mydatasource {
    @Profile("dev")//当这个环境被激活的时候才会加入这个组件
    @Bean
    public static MyDataSource dev(){
        MyDataSource myDataSource = new MyDataSource();
        myDataSource.setUrl("jdbc:mysql://localhost:3306/dev");
        myDataSource.setUsername("root");
        myDataSource.setPassword("<PASSWORD>");
        return myDataSource;
    }
    @Profile("test")
    @Bean
    public static MyDataSource test(){
        MyDataSource myDataSource = new MyDataSource();
        myDataSource.setUrl("jdbc:mysql://localhost:3306/text");
        myDataSource.setUsername("root");
        myDataSource.setPassword("<PASSWORD>");
        return myDataSource;
    }

    @Profile("prod")
    @Bean
    public static MyDataSource prod(){
        MyDataSource myDataSource = new MyDataSource();
        myDataSource.setUrl("jdbc:mysql://localhost:3306/prod");
        myDataSource.setUsername("root");
        myDataSource.setPassword("<PASSWORD>");
        return myDataSource;
    }
}
